﻿<input id="speech" type="text" speech="speech" x-webkit-speech="x-webkit-speech"
    onspeechchange="processspeech();" onwebkitspeechchange="processspeech();" />
<script type="text/javascript">
    function processspeech() {
        //alert($('#speech').val());
        $.ajax({
            type: "GET",
            url: '@Url.Content("~/Home/speech")',
            data: { data: $('#speech').val() },
            contentType: "application/json; charset=utf-8",
            cache: false,
            dataType: "html",
            success: function (result) {
                result = result.replace(/"/gi, '');
                if (result == "error") {
                    alert($('#speech').val() + '-speech could not be recognised');
                }
                else {
                    window.location.href = '@Url.Content("~/")' + result;
                }
            },
            error: function (result) {
            }
        });
    }
</script>
